#include "stdafx.h"
#include "seq_writer.h"
#include <imglib/io.h>
#include <mswin/file_dir.h>

namespace irender {

seq_writer::seq_writer(string const & pattern, bool alpha, string const & format) :
	name_factory_(pattern),
	alpha_(alpha),
	format_(format)
{
	assert(!pattern.empty());
	if (format_.empty())
		mswin::splitpath(pattern, 0, 0, 0, &format_);

	if (format_.size() > 0 && format_[0] == '.')
		format_ = format_.substr(1);
}

seq_writer & seq_writer::add(byte_image const & img)
{
	img::our_gdiplus_multiwriter().write(name_factory_.get_next(), format_, img, alpha_);
	return * this;
}

} //namespace irender
